<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>14_自定义Promise</title>
</head>

<body>
  <script src="./08lib/Promise14.js"></script>
  <script>
  	const p = new Promise((resolve, reject) => {
  		setTimeout(() => {
    			// resolve(1)
    			 reject(2)
  		}, 100)
  	}).then(
  		value => {
  			console.log('onResolved1()', value)
  		},
  		reason => {
  			console.log('onRejected1()', reason)
  			// return 3
  			// throw 4
  			return new Promise((resolve, reject) => reject(5))
  		}
  	).then(
  		value => {
  			console.log('onResolved2()', value)
  		},
  		reason => {
  			console.log('onRejected2()', reason)
  			throw 6
  		}
  	).catch(reason => {
  		console.log('onResolved3()', reason)
			return new Promise(() => {}) // 中断promise链
  	}).then(
  		value => {
  			console.log('onResolved4()', value)
  		},
  		reason => {
  			console.log('onRejected4()', reason)
  		}
  	)
  </script>
</body>

</html>